<%--                                                                       --%>
<%-- Copyright (c) 2001-2005 BroadVision, Inc.  All rights reserved.       --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries.                       --%>
<%--                                                                       --%>

<%@ page language="java" %>

<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>

<script language="javascript" src="<%= request.getContextPath() %>/cs/js/stringFunc.js" type="text/javascript">
</script>


<script language="JavaScript">

function onClickMyComputer(theForm) 
{   
  theForm.uploadFile.disabled=false;
  theForm.iconPath.disabled=true;
}

function onClickWebServer(theForm) 
{   
  theForm.uploadFile.disabled=true;
  theForm.iconPath.disabled=false;
}

// Go to microsite list page after clicking cancel button 
function onClickCancel(theForm) {
 if (confirm('<bean:message key="cs.confirm.cancel.microsite"/>') ){
    theForm.action = '<c:url value="/cs/microsite/cancelWizard.do"/>';
    theForm.submit();
    return;
  } else {
    return false;
  }
}

function onFileInputFocus(theForm)
{
   return theForm.uploadFile.focus();
}


function onClickNext(theForm) {
  if (doValidation(theForm)) {
    <c:if test="${!msNewForm.map.usePhase}">
      theForm.action = '<c:url value="/cs/microsite/participantList.do"/>';
    </c:if>
    theForm.submit();
    return true;
  }
  return false;
}

function onLoad()
{
   focus();
}

function doValidation(theForm) {
  
  if (validateWizardNewForm(theForm) == false) {
    return false;
  }
  
  
  /*if ( document.msNewForm.logoImage[1].checked ) {
    var filePath = document.msNewForm.uploadFile.value;
    if ( filePath.length != 0 ) {
      alert('<bean:message key="ep.error.remove.my.computer.path.before.next"/>');
      return;
    }
  }
  else {
    var filePath = theForm.uploadFile.value;
    if (filePath.length != 0) {
      var idx = filePath.lastIndexOf('\\');
      if (idx == -1) idx = filePath.lastIndexOf('/');
      if (idx == -1) idx = 0;
      if (filePath.length - idx > 255 - 11) {
        // Current we prepend string "/microsite/" in front of the
        // filename. 
        alert('<bean:message key="ep.error.microsite.logo.filename"/>');
        return;
      }
    }
  }
*/
  var iconPath = theForm.iconPath.value;
  
  if (!validateIconPath(iconPath)) {
    return false;
  }
  
  
  // check the icon path for user friendly mesg

  return true;
}

// should not start with 'http' or other weird characters.
// should start with '/'. 
function validateIconPath(iconPath) {
  if (iconPath == null || iconPath.length == 0) return true;
  if (stringTrim(iconPath).length == 0) return true; 
  
  var re = /^(http)/i;
  
  // first test whether starting with http
  var invalidStart = iconPath.match(re);
  
  if (invalidStart) {
    alert("<bean:message key='cs.error.microsite.iconPath1'/>");
    return false;
  }
  
  re = /^\//;
  var validStart = iconPath.match(re);
  if (!validStart) {
    alert("<bean:message key='cs.error.microsite.iconPath2'/>");
    return false;
  }
  
  return true;
}

</script>

<html:javascript formName="/cs/microsite/phaseList" method="validateWizardNewForm"/>

<html:form action="/cs/microsite/phaseList.do">

<html:hidden name="msNewForm" property="templateId"/>
<!-- Begin display logo and microsite name.  -->
<!-- Zone 5 starts here.  -->
      
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" 
       summary="content area">
  <tr>
    <td valign="top">
    
    <div class="pageTitle">
      <bean:message key="ep.wizard.pageTitle" 
                    arg0="${msNewForm.map.currentStep}"/><bean:message key="cs.details"/>
    </div>

    <div class="pageSubtitle">
 	<span class="left">&nbsp;</span>
 	<span class="right">&nbsp;</span>
    </div>
		
		<div class="blockWrap">
    <!-- start Page Instructions -->
    <div class="pageInstructions">
      <bean:message key="cs.microsite.note"/>
    </div>
    <!-- End Page Instructions -->
    
    
    <!--start main content area here-->
    <table class="labelForm" width="100%" border="0" cellspacing="0" 
           cellpadding="0" summary="Microsite Wizard new page">
             
      <tr> 
        <td nowrap width="20%" class="label"><bean:message key="cs.microsite.name"/>*: </td>
        <td width="80%" nowrap class="labelField"> 
          <html:text property="name" size="45" maxlength="80"/>
        </td>
      </tr>
      
      <tr>
        <td nowrap width="20%" class="label"><bean:message key="cs.microsite.url.name"/>: </td>
        <td nowrap width="80%" class="labelField">
          <bean:message key="cs.microsite.url.note"/><br>
          <html:text property="urlName" maxlength="80" size="31"/>
         </td>
      </tr>

      <tr>
        <td nowrap width="20%" class="label">
          <bean:message key="cs.description"/>:</b></td>
        <td width="80%" nowrap class="labelField">
          <html:textarea property="description" rows="4" cols="45"/>
        </td>
      </tr>
  
      <tr>
        <td nowrap width="20%" class="label">
          <bean:message key="cs.goal"/>:
        </td>
        <td width="80%" nowrap class="labelField">
          <html:textarea property="goal" rows="4" cols="45"/>
        </td>
      </tr>
      <tr>
        <td nowrap width="20%" class="label">
          <bean:message key="cs.microsite.logo.image.location"/>:
        </td>
        <td width="80%" align=left colspan=3 class="labelField">
          <bean:message key="cs.microsite.logo.edit.note1"/><br>
          <table cellspacing="0" cellpadding="4" border="0">
            <tr>
              <td class="labelField">
                <html:text property="iconPath" size="45" maxlength="255"/>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
	
    <!--start cancel, reset, save bar area here-->
    <div class="pageButtonWrap" align="right">             
      <html:button styleClass="pageButton" property="cancelBtn" titleKey="button.cancel" onclick="onClickCancel(this.form)">
        <bean:message key="button.cancel"/>
      </html:button>
      
      <html:button styleClass="pageButton" property="nextBtn" 
      						 titleKey="button.next"
      						 onclick='return onClickNext(this.form);'>
          <bean:message key="button.next"/>
      </html:button>
    </div>         
 </div>   
    </td>
  </tr>
</table>
 
<!--end cancel, reset, save bar area here -->
</html:form>


